<%@ taglib prefix="c" uri="http://java.sun.com/jsp/jstl/core"%>
<%@taglib prefix="sj" tagdir="/WEB-INF/tags/spring-jquery-tags"%>
<%@ taglib prefix="spring" uri="http://www.springframework.org/tags"%>
<%@ taglib prefix="form" uri="http://www.springframework.org/tags/form"%>
<%@ taglib prefix="fn" uri="http://java.sun.com/jsp/jstl/functions"%>
<link href="<c:url value='/css/cipe-ver2.css' />"	rel="stylesheet" type="text/css" />


<div id="paymentRequest" style="border:3px solid black; background-color:#ffffff; padding-left:20px; padding-bottom:10px; font-size:100%; text-align:left;">
<div  class="form_head">
	  <label style="font-size: 14px"><b>Payment Request Report</b> </label>
		<div class="floatR">
		  			<input type="image" src="<c:url value='/images/cross-button.jpg'/>" onClick="javascript:clearDiv()"/>				  
		</div>
	
</div>
		<form:form name="activeProjectQueryForm" id="activeProjectQueryForm" target="_blank" modelAttribute="paymentRequest" method="post">
		<table cellpadding="0" cellspacing="4" border="0">
			<tr>
				<td class="label">
					<spring:message code="editPaymentrequest.label.paymentIdentifiedInformation" />			
				</td>
				<td class="input-field">
						<form:input path="id"  id="paymentRequestId" tabindex="1" />
						<form:errors path="id" cssClass="error" />			
				</td>
			</tr>
						<tr><td>&nbsp;</td></tr>
			<tr><td>&nbsp;</td></tr>
			<tr>
				<td >
					<a href="#" id="printWireForm" class="uneditable blue_btn"><spring:message code="editPaymentrequest.label.printWireForm" /></a>
				</td>
				  <td >
					<a class="blue_btn" id="printPaymentRequest" href="#" style="display: none;" onclick="return false;">&nbsp;</a>				
<!-- 			           	<a class="blue_btn" id="printPaymentRequest" href="#"  onclick="return false;">PaymentRequestForm</a>				 -->
			           
			   </td>
			</tr>
			<tr><td>&nbsp;</td></tr>
			<tr><td>&nbsp;</td></tr>
			<tr>
			 
			</tr>

		</table>
	</form:form>
</div>
<script type="text/javascript">

	function clearDiv() {
		Popup.hide('activeProjectQueryInput1');
		 $('#activeProjectQueryInput1').html("");
	}
	
	$('#paymentRequestId').blur(function(){
		if($(this).val()!="")
        {			
		  loadDataViaAjax("loadPaymentRequest.do", {
			   "paymentId" : $(this).val()
			  }, parsePaymentJson);
        }else
        	{
        	$('#printPaymentRequest').css('display','none');
        	}
	});
	function parsePaymentJson(data){
		
		if(data==1 || data==2 || data==4 || data==6) {
			$('#printPaymentRequest').text('Print Payment Request Form');
			$('#printPaymentRequest').css('display','inline');
		}
		else if(data== 3) {
			$('#printPaymentRequest').text('Print Partner Payment Request Form');
			$('#printPaymentRequest').css('display','inline');
		} else if(data == 5){
			$('#printPaymentRequest').text('Print Reclass Form');
			$('#printPaymentRequest').css('display','inline');
		} else {
			$('#printPaymentRequest').css('display','none');
		}
		
	}
	
	$('#printWireForm').click(function() {
		$(this).bind("ajaxSend", function(){
            $('#loading').remove();
			$(this).after("<img  id='loading' src='<c:url value='/images/ajax-loader.gif'/>' alt='loading' />");
	
			 }).bind("ajaxComplete", function(){
	
				$('#loading').remove();
	
		 });
		window.open("<c:url value='/secure/showBankWireTransferPdf.do' />?paymentRequestId=" + "${paymentrequest.id}", "_blank").focus();
		clearDiv();
	});
	
	$('#printPaymentRequest').click(function() {
		$(this).bind("ajaxSend", function(){
            $('#loading').remove();
			$(this).after("<img  id='loading' src='<c:url value='/images/ajax-loader.gif'/>' alt='loading' />");
	
			 }).bind("ajaxComplete", function(){
	
				$('#loading').remove();
	
		 });
		var reportType = $('#printPaymentRequest').html();
		if($.trim(reportType) == 'Print Payment Request Form') {
			window.open("<c:url value='/secure/printPaymentRequestFormPdf.do' />?paymentRequestId=" + "${paymentrequest.id}", "_blank").focus();
		}
		if($.trim(reportType) == 'Print Partner Payment Request Form') {
			window.open("<c:url value='/secure/printPartnerPaymentRequestPdf.do' />?paymentRequestId=" + "${paymentrequest.id}", "_blank").focus();
		}
		if($.trim(reportType) == 'Print Reclass Form') {
			window.open("<c:url value='/secure/printReclassFormPdf.do' />?paymentRequestId=" + "${paymentrequest.id}", "_blank").focus();
		}
		clearDiv();
	});

</script>
